/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkl53.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HP G42 (RILLA)
 */
@Entity
@Table(name = "no_bs")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "NoBs.findAll", query = "SELECT n FROM NoBs n"),
    @NamedQuery(name = "NoBs.findByB1r1", query = "SELECT n FROM NoBs n WHERE n.noBsPK.b1r1 = :b1r1"),
    @NamedQuery(name = "NoBs.findByB1r2", query = "SELECT n FROM NoBs n WHERE n.noBsPK.b1r2 = :b1r2"),
    @NamedQuery(name = "NoBs.findByB1r3", query = "SELECT n FROM NoBs n WHERE n.noBsPK.b1r3 = :b1r3"),
    @NamedQuery(name = "NoBs.findByB1r5a", query = "SELECT n FROM NoBs n WHERE n.noBsPK.b1r5a = :b1r5a")})
public class NoBs implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected NoBsPK noBsPK;
    @OneToMany(mappedBy = "b1r5a")
    private List<B1Tempat> b1TempatList;
    @OneToMany(mappedBy = "b1r5a")
    private List<B1Keterangantempat> b1KeterangantempatList;
    @JoinColumn(name = "B1R3", referencedColumnName = "B1R3", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Kelurahan kelurahan;
    @JoinColumn(name = "B1R2", referencedColumnName = "B1R2", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Kelurahan kelurahan1;
    @JoinColumn(name = "B1R1", referencedColumnName = "B1R1", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Kelurahan kelurahan2;

    public NoBs() {
    }

    public NoBs(NoBsPK noBsPK) {
        this.noBsPK = noBsPK;
    }

    public NoBs(String b1r1, String b1r2, String b1r3, String b1r5a) {
        this.noBsPK = new NoBsPK(b1r1, b1r2, b1r3, b1r5a);
    }

    public NoBsPK getNoBsPK() {
        return noBsPK;
    }

    public void setNoBsPK(NoBsPK noBsPK) {
        this.noBsPK = noBsPK;
    }

    @XmlTransient
    public List<B1Tempat> getB1TempatList() {
        return b1TempatList;
    }

    public void setB1TempatList(List<B1Tempat> b1TempatList) {
        this.b1TempatList = b1TempatList;
    }

    @XmlTransient
    public List<B1Keterangantempat> getB1KeterangantempatList() {
        return b1KeterangantempatList;
    }

    public void setB1KeterangantempatList(List<B1Keterangantempat> b1KeterangantempatList) {
        this.b1KeterangantempatList = b1KeterangantempatList;
    }

    public Kelurahan getKelurahan() {
        return kelurahan;
    }

    public void setKelurahan(Kelurahan kelurahan) {
        this.kelurahan = kelurahan;
    }

    public Kelurahan getKelurahan1() {
        return kelurahan1;
    }

    public void setKelurahan1(Kelurahan kelurahan1) {
        this.kelurahan1 = kelurahan1;
    }

    public Kelurahan getKelurahan2() {
        return kelurahan2;
    }

    public void setKelurahan2(Kelurahan kelurahan2) {
        this.kelurahan2 = kelurahan2;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (noBsPK != null ? noBsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NoBs)) {
            return false;
        }
        NoBs other = (NoBs) object;
        if ((this.noBsPK == null && other.noBsPK != null) || (this.noBsPK != null && !this.noBsPK.equals(other.noBsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pkl53.model.NoBs[ noBsPK=" + noBsPK + " ]";
    }
    
}
